﻿@model XPressify.Models.ProfileViewModel
@using XPressify.Data.Helpers
@using XPressify.Models
@using Omu.Awesome.Core;
@using Omu.Awesome.Mvc.Helpers;
@using XPressify.Controllers

@if (Model.IsAjaxRequest)
{
    ViewBag.Title = "Profile";
}
else
{
    ViewBag.Title = "Profile";
    Layout = "~/Views/Shared/_Layout.cshtml";
}


<script type="text/javascript">

    $(function () {
        $("#tabs").tabs({
            ajaxOptions: {
                error: function (xhr, status, index, anchor) {
                    $(anchor.hash).html(
						"Couldn't load this tab.");
                }
            }
        });
    });

    $(document).ready(function () {
        $("#maincol").css('padding', '0px');
        $('#ui-tabs-1').css('font', '13px "Trebuchet MS", Verdana, Helvetica, sans-serif');
        $('.nobtn').css('color', 'blue');

    });

    
</script>

@if (!Model.IsAjaxRequest)
{
    if (!Model.IsBlocked)
    {
        <div id="tabs">
            <ul>
	            <li><a href="/Profile/ProfileView/@Model.OwnerUser.Id">Profile</a></li>
                <li><a href="/Profile/ProfileInfo/@Model.OwnerUser.Id">Info</a></li>
	            <li><a href="/Profile/FriendListPopup/@Model.OwnerUser.Id">Friends</a></li>
                <li><a href="/Album/AlbumViewerList/@Model.OwnerUser.Id">Albums</a></li>
        
            </ul>
        </div>
    }
}


@if (Model.IsAjaxRequest)
{



    if (!Model.IsBlocked)
    {

        if ((Model.IsOwner == true) ||
        (Model.IsOwner == false && Model.IsFriend == false && Model.OwnerUser.PrivacyType == SubjectPrivacy.Public) ||
        (Model.IsOwner == false && Model.IsFriend == true))
        {
                <div>
                    <table>
                        <tr>
                            <td style="width:180px">
                                <a href='@Url.Action("AlbumDetails", "Album", new { id = Model.ProfileAlbumId })' class="nobtn">
                                    <img src="@Model.OwnerProfilePicturePath" alt="Profile picture" title="Profile picture" class="nobtn" style="max-width:180px;max-height:240px"/>
                                </a>
                     
                            </td>
                            <td>
                                <h1>@Model.OwnerUser.FullName</h1>
                                Born: @Model.OwnerUser.Birthday.ToString("dd MMMM yyyy") <br />
                                Email: @Model.OwnerUser.Email <br />
                                @if (Model.previousLoveRelationshipUser != null)
                                {
                                    <text>Relationship status: </text>
                                    @Model.LoveRelationshipType
                               if (Model.LoveRelationshipWithHimself == false)
                               {
                                        <text> with </text>
                                        @Html.ActionLink(Model.previousLoveRelationshipUser.FullName, "ProfileView", "Profile", new { id = Model.previousLoveRelationshipUser.Id }, new { style = "color:blue", @class = "nobtn" })
                               }
                                    <br />
                                }
                    
                                @(Html.MakePopupForm<ProfileController>(o => o.FamilyList(Model.OwnerUser.Id), title: "Family", height: 500, width: 400, okText: "", resizable: false, refreshOnSuccess: true))
                                @(Html.PopupFormActionLink<ProfileController>(o => o.FamilyList(Model.OwnerUser.Id), "Family", new { @class = "nobtn", style = "color:blue" }))
                            </td>
                        </tr>
                        @if (Model.IsOwner)
                        {
                            <tr>
                                <td style="text-align:center">
                                    @(Html.MakePopupForm<AlbumController>(o => o.AlbumUploadFileNormal(Model.ProfileAlbumId), title: "Upload", height: 340, width: 600, okText: "", resizable: false, refreshOnSuccess: true))
                                    @(Html.PopupFormActionLink<AlbumController>(o => o.AlbumUploadFileNormal(Model.ProfileAlbumId), "Upload profile picture", new { @class = "nobtn", style = "color:blue" }))
                                </td>
                                <td></td>
                            </tr>
                        }
                    </table>
        
         
                </div>
    
    
        }

        <br />
 

        <br />

        if (Model.IsOwner == false && Model.IsFriend == false && Model.AnyFriendRelationship == false)
        {
            <div> @Html.ActionLink("Add as a friend", "AddFriend", "User", new { id = Model.OwnerUser.Id }, new { @class = "abtn" }) </div>
        }
        if (Model.OwnerRequestedFriendshipExist)
        {
            <div style="text-align:right"> @Html.ActionLink("Accept as friend", "ConfirmRelationship", "Profile", new { id = Model.OwnerRequestedFriendshipRel.Id }, new { @class = "abtn" }) </div>
        }

        if (Model.IsOwner == false && Model.IsFriend == true)
        {
            <div> 
                @Html.Confirm("Are you sure you want to remove from friends?", "myconfirmBtn2", title: "Remove friend", yesText: "Delete")           
                @using (Html.BeginForm("RemoveFriend", "User", FormMethod.Get, new { style = "width:20px;color:blue" }))
                {
                        <input type="hidden" value="@Model.OwnerUser.Id" name="id" />
                        <input type="submit" value="Remove friend" class="myconfirmBtn2" style="padding:0px;font-weight:normal" id="nounderline" onmouseover="changeIdToObject(this)" onmouseout="changeIdToObject(this)"/>
                }
            </div>
        }
        if (Model.IsOwner == false)
        {
            <div>
                @Html.Confirm("Are you sure you want to block this person?", "myconfirmBtn3", title: "Block user", yesText: "Block")           
                @using (Html.BeginForm("BlockUser", "User", FormMethod.Get, new { style = "width:20px;color:blue" }))
                {
                        <input type="hidden" value="@Model.OwnerUser.Id" name="id" />
                        <input type="submit" value="Block this person" class="myconfirmBtn3" style="padding:0px;font-weight:normal" id="nounderline" onmouseover="changeIdToObject(this)" onmouseout="changeIdToObject(this)"/>
                } 
            </div>
            <br />
        }

        @*
        if ((Model.IsOwner == true) ||
            (Model.IsOwner == false && Model.IsFriend == false && Model.OwnerUser.PrivacyType == SubjectPrivacy.Public) ||
            (Model.IsOwner == false && Model.IsFriend == true))
        { 
        <div> 
            @if (Model.IsOwner)
            {
                @Html.ActionLink("Albums", "AlbumOwnerList", "Album", new { }, new { style = "color:blue" }) 
            }
            else
            {
                @(Html.MakePopupForm<AlbumController>(o => o.AlbumViewerList(Model.OwnerUser.Id, 1), title: "Albums", height: 600, width: 900, okText: "", resizable: false, refreshOnSuccess: true))
                @(Html.PopupFormActionLink<AlbumController>(o => o.AlbumViewerList(Model.OwnerUser.Id, 1), "Albums", new { @class = "nobtn", style = "color:blue" }))
            }
        </div>
     
        }*@

        <br />


        @Html.Partial("ShareLabel", new ShareLabelModel { LinkSubjectId = Model.OwnerUser.Id, WallAlbumId = Model.WallAlbumId })     
    
    
   if (Model.IsOwner)
   {
            <div id="contentHolderWrite">
                @Html.Partial("WriteStatus", new StatusCreateModel { Content = "Whats on your mind?", UserPostedOnId = Model.OwnerUser.Id, BaseSubjectType = Model.OwnerUser.Type })    
            </div>
   }
   else
   {
            <div id="contentHolderWrite">
                @Html.Partial("WriteStatus", new StatusCreateModel { Content = "Write something...", UserPostedOnId = Model.OwnerUser.Id, BaseSubjectType = Model.OwnerUser.Type })    
            </div>        
   }

        <br />
    
        <div id="returnSuccessDelete"></div>
        <div id="specialPeopleLikeList" style="display:none"></div> 
        @Html.Confirm("Are you sure you want to delete this post?", "myconfirmBtn", title: "Delete post", yesText: "Delete")
        @Html.Confirm("Are you sure you want to delete this comment?", "myconfirmBtn1", title: "Delete comment", yesText: "Delete")

        <text>______________________________________________________________________________</text>

        <div id="@Model.OwnerUser.Id"></div>
        
            var index = 0;
            var specialUpdateId = "";
            foreach (var item in Model.Posts)
            {
                <div id="@item.Key.Id">
                    <table border="0" cellpadding="0" cellspacing="0" style="margin:0px;padding:0px;width:553px">
                        <tr>
                            <th style="padding: 0px 2px 0px 2px;"> 
                                @Html.Raw(item.Key.Content)
                            </th>
                            @if (item.Key.BaseSubject.Id == Model.ViewerUserId || (item.Key.Creator != null && item.Key.Creator.Id == Model.ViewerUserId))
                            {
                                <td style="padding: 0px 2px 0px 2px;vertical-align:top;background-color: #E8EEF4;text-align:right">
                                    @Html.Partial("BtnPostDelete", new BtnPostDeleteModel { PostId = item.Key.Id })
                                </td>
                            }
                        </tr>
                    </table>
   
                    @foreach (var comment in item.Value)
                    {   
                        <div id="@comment.Id">
                            <table border="0" cellpadding="0" cellspacing="0" style="margin:0px;padding:0px;width:553px">
                                <tr>
                                    <th width="0px" style="padding: 0px 2px 0px 2px"> 
                                        @Html.Raw(comment.Content)
                                    </th>
                                    @if (comment.BaseSubject.Id == Model.ViewerUserId || Model.IsOwner)
                                    {
                                        <th style="padding: 0px 2px 0px 2px;vertical-align: top;text-align:right"> 
                                            @Html.Partial("BtnPostCommentDelete", new BtnPostDeleteModel { PostId = comment.Id })
                                        </th>
                                    }
                                </tr>
                            </table>
                        </div>
        
                    }
                    @{specialUpdateId = item.Key.Id + "Update";}
                    <div id="@specialUpdateId"></div>
    
                    @if (item.Key.CommentType != CommentType.PostWithoutComments)
                    {
                        @Html.Partial("WriteComment", new PostCommentModel { PostId = item.Key.Id, ContentText = "Write a comment...", ProfilePicturePath = Model.ViewerProfilePicturePath })
                    }
    
                    ______________________________________________________________________________
                </div>
            }

    }


}